package com.ny.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Demo {
    public static  void menu(){
        System.out.println("欢迎来到此系统");
        System.out.println("0.退出系统");
        System.out.println("1.添加员工");
        System.out.println("2.查询所有员工");
        System.out.println("3.根据工号查询");
        System.out.println("4.据员工编号进行删除");
        System.out.println("5.根据员工编号修改某个员工信息");
        System.out.println("请选择你要进行的操作");
    }
    public static void main(String[] args) {
        TestList testlist = new TestList();
        List<Employee> list = new ArrayList();
        boolean flag = true;
        while (flag){
            menu();
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            switch (n){
                case 0:
                    flag=false;
                    break;
                case 1:
                    //调用addEmployee 给list添加员工
                    System.out.println("请输入员工信息");
                    System.out.println("1.请输入员工工号");
                    String employeeNumber= scanner.next();
                    System.out.println("2.请输入员工姓名");
                    String employeeName= scanner.next();
                    System.out.println("3.请输入员工年龄");
                    int employeeAge= scanner.nextInt();
                    Employee addemployee = new Employee(employeeNumber,employeeName,employeeAge);
                    testlist.addEmployee(list, addemployee);
                    System.out.println(list);
                    break;
                case 2:
                    //调用findallemp，查询所有员工
                    testlist.findAllEmployee(list);
                    break;
                case 3:
                    //findempname，根据工号查询

                    Scanner s = new Scanner(System.in);
                    System.out.print("请输入要查询的员工工号：");
                    Employee employee = testlist.findEmployeeNumber(list, scanner.next());
                    System.out.println(employee);
                    break;
                case 4:
                    //deleteEmployeeNumber根据员工编号进行删除
                    System.out.println("请输入你要删除的员工编号");

                    String number = scanner.next();

                    testlist.deleteEmployeeNumber(list, number);
                    break;
                case 5:
                    //根据员工编号修改某个员工信息，例如10001的年龄修改成20
                    System.out.println("请输入要修改的员工编号");
                    String updateEmNumber = scanner.next();

                    Employee updateEmployee = testlist.findEmployeeNumber(list, updateEmNumber);
                    System.out.println("请输入要修改的员工年龄");
                    int updateAge = scanner.nextInt();
                    updateEmployee.setAge(updateAge);

                    testlist.updateEmployee(list, updateEmployee);
                    break;
            }
        }
    }
}
